package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

//集合的排序:整数
public class SortInteger {
    public static void main(String[] args) {
        Random rand=new Random();
        List<Integer> list=new ArrayList<>();
        for(int i=0;i<10;i++){
            list.add(rand.nextInt(100));
        }
        System.out.println(list);//[39, 28, 82, 62, 9, 6, 83, 14, 68, 34]

        //调用Collections类中的升序方法
        Collections.sort(list);
        System.out.println(list);//[6, 9, 14, 28, 34, 39, 62, 68, 82, 83]

        //反转
        Collections.reverse(list);
        System.out.println(list);//[83, 82, 68, 62, 39, 34, 28, 14, 9, 6]



    }
}
